/********************************************
Name : TestCreateCaseRequest_WS
Created By : dthekumparampil
Created Date : Jan 27, 2013
Description : Test Coverage for CreateCaseRequest_WS
********************************************/

@isTest
private class TestCreateCaseRequest_WS {
	
	/*Condition where ID is found in Account*/
	static testMethod void foundInAccount(){
		
		/****Creating Test Database****/
    	Account testAccount = TestDatabaseCMS.createAccountForTesting();
    	West_Case_Names__c testCaseNames = TestDatabaseCMS.createWestCaseNames();

		/****Testing****/
		test.startTest();
    	String foundInAccount = CreateCaseRequest_WS.createCase(testAccount.Account_Id__C, 'Academic Probation', 'Subject', 'Description');
    	test.stopTest();
    	
    	/****Asserting correctness****/
    	System.assert(foundInAccount.contains('Success'));
	}
	
	/*Condition where ID is found in Account but unable to create Case*/
	static testMethod void foundInAccountERR(){
		
		/****Creating Test Database****/
    	Account testAccount = TestDatabaseCMS.createAccountForTesting();

		/****Testing****/
		test.startTest();
    	String foundInAccount = CreateCaseRequest_WS.createCase(testAccount.Account_Id__C, 'Academic Probation', 'Subject', 'Description');
    	test.stopTest();
    	
    	/****Asserting correctness****/
    	System.assert(foundInAccount.contains('Failure'));
	}
	
	/*Condition where ID is found in Lead*/
	static testMethod void foundInLead(){
		
		/*Creating Test Database*/
		West_Case_Names__c caseNameRecord = TestDatabaseCMS.createWestCaseNames();
		Lead testLead = TestDatabaseCMS.createLeadForTesting();

		/*Testing*/
		test.startTest();
    	String foundInLead = CreateCaseRequest_WS.createCase(testLead.Lead_Id__C, 'Academic Probation', 'Subject', 'Description');
    	test.stopTest();
    	
    	/*Asserting correctness*/
    	System.assert(foundInLead.contains('Success'));
	}
	
	/*Condition where ID is found in Lead but unable to create Case*/
	static testMethod void foundInLeadERR(){
		
		/*Creating Test Database*/
		Lead testLead = TestDatabaseCMS.createLeadForTesting();

		/*Testing*/
		test.startTest();
    	String foundInLead = CreateCaseRequest_WS.createCase(testLead.Lead_Id__C, 'Academic Probation', 'Subject', 'Description');
    	test.stopTest();
    	
    	/*Asserting correctness*/
    	System.assert(foundInLead.contains('Failure'));
	}
	
	/*Condition where ID is not found in Salesforce*/
	static testMethod void notfoundInSalesforce(){

		/*Testing*/
		test.startTest();
    	String notfoundInSalesforce = CreateCaseRequest_WS.createCase('0001ddsd', 'Academic Probation', 'Subject', 'Description');
    	test.stopTest();
    	
    	/*Asserting correctness*/
    	System.assert(notfoundInSalesforce.contains('Failure'));
	}
	
	/*Condition where mandatory field is missing*/
	static testMethod void missingField(){
		/*Testing*/
		test.startTest();
    	String missingField = CreateCaseRequest_WS.createCase('0001ddsd', 'Academic Probation', '', 'Description');
    	test.stopTest();
    	
    	/*Asserting correctness*/
    	System.assert(missingField.contains('Failure'));
	}
}